package com.inno.thread.innot.communication;

import java.util.concurrent.TimeUnit;

public class DemoVolatileUse {
    public static void main(String[] args) throws InterruptedException {
        Game game = new Game();
        game.setRunning(true);

        Thread p1 = new Thread(new DoublePersonGame(game),"玩家一");

        DoublePersonGame target = new DoublePersonGame(game);
        Thread p2 = new Thread(target,"玩家二");

        p1.start();
        p2.start();
       /* while (true) {
            TimeUnit.SECONDS.sleep(1);
        }*/
        TimeUnit.SECONDS.sleep(10);
        target.cancel();
    }
}
